rm(list = ls())
library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
linkWorld_gpkg="https://github.com/krlos20203563/ASIE_2024-1/raw/main/data_TA2/maps/worldMap.gpkg"
sf::st_layers(linkWorld_gpkg)
## Driver: GPKG
## Available layers:
## layer_name geometry_type features fields crs_name
## 1 countryBorders 252 1 WGS 84
## 2 riverLines 98 2 WGS 84
## 3 cityPoints Point 610 3 WGS 84
countries=read_sf(linkWorld_gpkg,layer="countryBorders")
rivers=read_sf(linkWorld_gpkg,layer="riverLines")
cities=read_sf(linkWorld_gpkg,layer="cityPoints")
##Mapa del mundo
library(plotly)
## Cargando paquete requerido: ggplot2
##
## Adjuntando el paquete: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
baseLayer <- plot_ly() %>%
add_sf(data = countries, fill = I('grey90'), color = I('black'), name = 'Countries', text = ~COUNTRY, hoverinfo = 'text')
final <- baseLayer %>%
add_sf(data = rivers, color = I('blue'), name = 'Rivers', text = ~NAME, hoverinfo = 'text', inherit = FALSE) %>%
add_sf(data = cities, color = I('red'), name = 'Cities', text = ~NAME, hoverinfo = 'text', inherit = FALSE) %>%
layout(
title = 'Mapa interactivo',
xaxis = list(title = 'Longitud'),
yaxis = list(title = 'Latitud'),
plot_bgcolor = 'lightgrey'
)
final
## No trace type specified:
## Based on info supplied, a 'scatter' trace seems appropriate.
## Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No trace type specified:
## Based on info supplied, a 'scatter' trace seems appropriate.
## Read more about this trace type -> https://plotly.com/r/reference/#scatter
## No trace type specified:
## Based on info supplied, a 'scatter' trace seems appropriate.
## Read more about this trace type -> https://plotly.com/r/reference/#scatter